package com.gemme.gemme.view;

import android.app.Activity;
import android.content.Context;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.gemme.gemme.R;
import com.gemme.gemme.util.DpUtil;
import com.gemme.gemme.util.ShapeUtil;

//首页水平滚动
public class SpecialPriceView extends RelativeLayout {
    private Context context;
    public SpecialPriceView(Context context) {
        this(context,null);
    }

    public SpecialPriceView(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public SpecialPriceView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context = context;
        initView();
    }
    ImageView iv;
    TextView tv_name;
    TextView tv_desc;
    TextView tv_price;
    TextView tv_dis_price;
    private void initView() {
        LayoutInflater.from(context).inflate(R.layout.special_price_view,this);
        LinearLayout ll_content = findViewById(R.id.ll_content);
//        ll_content.setBackground(ShapeUtil.getCornBg(DpUtil.dp2px((Activity) context,9),"#ffffffff"));
//        setBackground(ShapeUtil.getCornBg(DpUtil.dp2px((Activity) context,9),"#ffffffff"));

        iv = findViewById(R.id.iv);
        tv_name = findViewById(R.id.tv_name);
        tv_desc = findViewById(R.id.tv_desc);
        tv_price = findViewById(R.id.tv_price);
        tv_dis_price = findViewById(R.id.tv_dis_price);
        tv_dis_price.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG); //中划线

    }

    public SpecialPriceView setIv(String str){
        Glide.with(context).load(str).into(iv);
        return this;
    }

    public SpecialPriceView settv_name(String str){
        tv_name.setText("" + str);
        return this;
    }
    public SpecialPriceView settv_desc(String str){
        tv_desc.setText("" + str);
        return this;
    }
    public SpecialPriceView settv_price(String str){
        tv_price.setText("¥"  + str);
        return this;
    }
    public SpecialPriceView settv_dis_price(String str){
        tv_dis_price.setText("¥" + str);
        return this;
    }
}
